/* 使用request向其他网站请求数据 */

var https = require('https');

var options = {
	hostname: 'npmjs.org',
	port: 443,
	path: '/',
	method: 'GET',
	agent: false
}

var req = https.request(options, function(res){
	console.log("statusCode: " + res.statusCode);

	console.log("header: ", res.headers);

	res.setEncoding('utf8');

	res.on('data', function(data){
		console.log("content: " + data);
	})
});

req.end();

req.on("error", function(err){
	console.log("error, " + err.code);
});